﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data;
using DevExpress.XtraReports.UI;
using DevExpress.LookAndFeel;

using QLTTAN.Report;
using QLTTAN.BLL;
namespace QLTTAN.Form
{
    public partial class frmBaoCaoHocVu : DevExpress.XtraEditors.XtraForm
    {
        KhoaHocBLL KH_BLL;

        public frmBaoCaoHocVu()
        {
            InitializeComponent();
        }

        private void frmBaoCaoHocVu_Load(object sender, EventArgs e)
        {
            KH_BLL = new KhoaHocBLL();

            try
            {
                DataTable dt = KH_BLL.KhoaHoc_Load();
                lookUpEditKhoaHoc.Properties.DataSource = dt;
                lookUpEditKhoaHoc.Properties.DisplayMember = "TenKhoaHoc";
                lookUpEditKhoaHoc.Properties.ValueMember = "MaKhoaHoc";

                lookUpEditKhoaHoc.ItemIndex = dt.Rows.Count - 1;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btnXemIn_Click(object sender, EventArgs e)
        {
            if(lookUpEditKhoaHoc.EditValue == null)
            {
                XtraMessageBox.Show("Bạn chưa chọn khóa học", "Thông báo!!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            rpBaoCaoHocVu rpbchv = new rpBaoCaoHocVu(int.Parse(lookUpEditKhoaHoc.EditValue.ToString()));

            using (ReportPrintTool printTool = new ReportPrintTool(rpbchv))
            {
                printTool.ShowPreviewDialog();
                printTool.ShowPreview(UserLookAndFeel.Default);
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}